import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'


export const queryMaterialById = (params) => {
  return getAction("/base/material/queryById", params);
}

export const queryMaterialVoInfoById = (params) => {
  return getAction("/base/material/getmaterialinfobymaterialid", params);
}

export const getbillcodebyobject = (params) => {
  return postAction("/base/basequeryreport/getbillcodebyobject", params);
}
export const queryMaterialVoInfosByIds = (params) => {
  return getAction("/base/material/getmaterialinfosbymaterialids", params);
}

export const getmaterialsecqty = (params) => {
  return getAction("/base/material/getsecqty", params);
}
export const queryWarehouseInfoById = (params) => {
  return getAction("/base/warehouse/queryById", params);
}
/**获取库存状态 */
export const getStocktype = () => {
  return getAction("/base/scmstocktype/list");
}

export const getInventoryKind = () => {
  return getAction("/base/scminventorykinds/list");
}

export const getscmbatchbycompanyidandmaterialid = (params) => {
  return getAction("/inventory.base/scmimbalance/getscmbatchbycompanyidandmaterialid", params);
}

export const getscmbatchlist = (params) => {
  return getAction("/inventory.base/scmimbalance/batchlist", params);
}

export const getpartnerinfo = (params) => {
  return getAction("/base/scmpartner/queryById", params);
}

export function uuid () {
  var s = [];
  var hexDigits = "0123456789abcdef";
  for (var i = 0; i < 32; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  }
  s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  s[8] = s[13] = s[18] = s[23];
  var uuid = s.join("");
  return uuid;
}

export function addDaysToDate (originalDate, numOfDays) {
  originalDate.setDate(originalDate.getDate() + numOfDays);
  return originalDate;
}

export const queryprintdatasourcebyobjectcode = (params) => {
  return getAction("/base/scmprintdatasource/queryprintdatasourcebyobjectcode", params);
}

export const queryprintdatasourcebyprintdefid = (params) => {
  return getAction("/base/scmprintdatasource/queryprintdatasourcebyprintdefid", params);
}

export const queryprojecttype = (params) => {
  return getAction("/base/projecttype/querylist", params);
}

export const querywarehousebycompanyid = (params) => {
  return getAction("/base/warehouse/list", params);
}

export const queryloginuserwarehouseid = (params) => {
  return getAction("/base/warehouselinkman/getloginuserwarehouseid", params);
}

/**
 * 获取物料类型分页列表数据
 * @param {*} params 
 * @returns 
 */
export const querymaterialtypelist = (params) => {
  return getAction("/base/materialtype/rootList", params);
}

/**
 * 批量获取物料类型的子类型
 * @param {*} params 
 * @returns 
 */
export const querymaterialchildlist = (params) => {
  return getAction("/base/materialtype/getChildListBatch", params);
}

export const gettrackbill = (params) => {
  return getAction("/sysplatform/trackbill/gettrackbill", params);
}

export const getfilterparams = (params) => {
  return getAction("/base/scmfilter/queryScmfilteritemByfitercode", params);
}

/**
 * 从excel读取数据
 * 
 * @param {excel列表} file 
 * @returns 
 */
export const readFile = (file) => {
  return new Promise(resolve => {
    let reader = new FileReader()
    reader.readAsBinaryString(file)
    reader.onload = ev => {
      resolve(ev.target.result)
    }
  })
}

export const getBominfo = (params) => {
  return getAction("/base/scmbillofmaterial/queryById", params);
}

export const getBomItemInfo = (params) => {
  return getAction("/base/scmbillofmaterial/queryScmbillofmaterialitemByMainId", params)
}


export const getBMModelInfo = (params) => {
  return getAction("/bm.matmodel/bmmatmodel/queryById", params);
}

export const getBMModelRuleInfo = (params) => {
  return getAction("/bm.matrule/bmrule/queryByModelId", params);
}


export const getSecAttrItemList = (params) => {
  return getAction("/base.secattr/scmsecattritem/getsecattritembyno", params);
}

export const getprintobjectbyobjectcode = (params) => {
  return getAction("/base/scmobject/getprintscmobjectbyobjectcode", params);
}


export const getCrmLinkmaninfobyparentid=(params)=>{
  return getAction("/crm.customerarchive/crmcustomerarchive/queryCrmcusarchlinkmanitemByMainId",params);
}